package com.pan.alg.leecode;

import java.util.*;

/**
 * 交集
 */
public class Part {

    Queue<Price> prices = new LinkedList<>();
    Queue<Discount> discounts = new LinkedList<>();
    List<Price> salePrices = new ArrayList<>();
    public void calculate(){

        Iterator<Price> priceIterator = prices.iterator();
        Iterator<Discount> discountIterator = discounts.iterator();

        while (priceIterator.hasNext()){
            Price pricePeek = prices.peek();
            while(discountIterator.hasNext()){
                Discount discountPeek = discounts.peek();
                //如果价格和折扣没有交集，折扣没有意义，去除
                if(pricePeek.start>=discountPeek.end){
                    discountIterator.remove();
                }else if(pricePeek.start<discountPeek.end){
                    if(pricePeek.start>discountPeek.start){
                        if(pricePeek.end<discountPeek.end){
                            Price price = new Price();
                            price.start = pricePeek.start;
                            price.end =pricePeek.end;
                            int result = calculate(pricePeek,discountPeek);
                            price.price = result;
                            salePrices.add(price);
                            priceIterator.remove();
                            break;
                        }else if(pricePeek.end>=discountPeek.end){

                        }
                    }else if(pricePeek.start<=discountPeek.start){
                        if(pricePeek.end<discountPeek.end){

                        }else if(pricePeek.end>=discountPeek.end){

                        }
                    }
                }
            }
        }
    }

    public int calculate(Price price,Discount discount){

        return 0;
    }


    private static class Price{
        int start;
        int end;
        int price;
    }
    private static class Discount{
        int start;
        int end;
        int discount;
    }
}

